// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

import GameConfig, { ShapeData, ShapeType } from "./GameConfig";

const {ccclass, property} = cc._decorator;

@ccclass
export default class GameData {

    private static shapeCount:number = 0;
    public static currentWaitSelectShapeBatcher:Array<ShapeData> = new Array(3);
    public static randomShapeBatcher() {
        this.currentWaitSelectShapeBatcher.length = 0;
        const keyList = Object.keys(ShapeType);
        for (let i = 0; i < 3; i++) {
            const shapeType = keyList[Math.floor(Math.random() * keyList.length)] as ShapeType;
            const color = GameConfig.getRandomColor();
            const gridPos = GameConfig.BEGIN_DOWN_GRID_POS.clone();
            this.currentWaitSelectShapeBatcher.push({
                id:GameData.shapeCount++,
                type: shapeType,
                color: color,
                gridPos: gridPos
            })
        }
    }

    public static getWaitSelectShapeData(index:number):ShapeData {
        if (this.currentWaitSelectShapeBatcher[index] == null) {
            return null;
        }
        return this.currentWaitSelectShapeBatcher[index];
    }
}
